---
id: environment-automation
title: Environment Automation
description: Tracetest allows the creation of an environment from the CLI and provisioning it with any type of resource, including tests, test suites, tracing backends, test runners, polling profiles, invites, tokens, etc.
keywords:
  - tracetest
  - trace-based testing
  - observability
  - distributed tracing
  - testing
  - test runs
  - test run groups
  - environments
image: https://res.cloudinary.com/djwdcmwdz/image/upload/v1698686403/docs/Blog_Thumbnail_14_rsvkmo.jpg
---

:::note
[Check out the the recipes section for a step by step tutorial using the Tracetest CLI here.](../examples-tutorials/recipes/provisioning-developer-environment-cli.mdx)
:::

:::note
[Check out the the recipes section for a step by step tutorial using a Bash Script here.](../examples-tutorials/recipes/provisioning-developer-environment-script.mdx)
:::

## Resource Definition

The Tracetest Web UI provides several options for maintaining Resource Definitions for Tracetest constructs.

### Tracing Backend

When you are in your tracing environment for your org, in **Settings**, under the **Tracing Backend** tab, you will find the link to the **Resource Definition** modal:

![Resource Definition](../img/resource-definition.png)

Clicking on the **Resource Definition** link will open the modal:

![Resource Definition Modal](../img/resource-definition-modal.png)

The YAML definition is in the left panel, where you can rename, download or copy the YAML file.

On the right are the automate commands for applying this resource in the CLI.

### Trace Polling

Similarly, on the **Trace Polling** tab, you will find the **Resource Definition** link for each polling profile in the trace:

![Trace Polling Resource Definition](../img/trace-polling-resource-definition.png)

Selecting the **Definition** link will open the **Resource Definition** modal:

![Trace Polling Resource Definition Modal](../img/trace-polling-resource-definition-modal.png)

### Demo

On the **Demo** tab, you will find link to work with resource definitions, as well:

![Demo Resource Definition](../img/demo-resource-definition.png)

### Analyzer

On the **Analyzer** tab, click on **Resource Definition**:

![Analyzer Resource Definition](../img/analyzer-resource-definition.png)

The analyzer modal shows one single action.

![Analyzer Resource Definition Modal](../img/analyzer-resource-definition-modal.png)

### Test Runner

On the **Test Runner** tab, click on **Resource Definition**:

![Test Runner Resource Definition](../img/test-runner-resource-definition.png)

![Test Runner Resource Definition Modal](../img/test-runner-resource-definition-modal.png)

### Variable Sets

In the navigation panel on the left of the screen, click on **Variable Sets**.


This will open the modal for the Variable Set's resource definition:

![Resource Definition Modal](../img/variable-set-resource-definition-modal.png)

## Provisioning Environments

Tracetest allows the creation of an environment from the CLI and provisioning it with any type of resource. 

The resources that can be provisioned in an environment are:

- `analyzer`
- `config`
- `datastore`
- `demo`
- `environment`
- `environmenttoken`
- `invite`
- `pollingprofile`
- `test`
- `testrunner`
- `testsuite`
- `variableset`

Use this feature to quickly spin up new environments for integration testing or CI builds.

:::note
You can find code examples [here](https://github.com/kubeshop/tracetest/tree/main/examples/environment-automation).
These files are in a folder called [“/resources”](https://github.com/kubeshop/tracetest/tree/main/examples/environment-automation/resources).
:::

```yaml title="environment.yaml"
type: Environment
spec:
  name: my-demo-env
  description: My env desc
  resources: ./resources # this is a folder
```
The apply command for creating this environment:

```bash title="Terminal"
tracetest apply environment -f ./path/to/environment.yaml
```

You will now see the created environment and all resources from the `resources` folder in the Tracetest Web UI.

![Environments](../img/environments.png)

![Environment Tests](../img/environment-tests.png)


## CI Environments

Environments can be created in an automation/CI pipeline without user interaction.

These environments can be generated for PRs or feature branches, when merging code, when deploying code to `QA`, `staging`, or beyond.

### Role Access

An automated environment can only be accessed by an `admin` or `owner` role. As a `member` role you will see a `Send Request` button when accessing the environment link. 

![request access](https://res.cloudinary.com/djwdcmwdz/image/upload/v1716963408/docs/no-access-min_1_zdsuie.png)

The `admin` and `owner` can grant access via an email they recieve after the request is clicked.

![grant access email](https://res.cloudinary.com/djwdcmwdz/image/upload/v1716962956/docs/image_67_kgtqkp.png)
